import { AfterViewInit, Component, OnInit } from '@angular/core';
import { NavController } from '@ionic/angular';
import { HttpService } from '../service/http.service';
import { MineService } from '../service/mine.service';

@Component({
  selector: 'app-login',
  templateUrl: './login.page.html',
  styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit, AfterViewInit {

  user = {
    username: '18007496225',
    password: 'e10adc3949ba59abbe56e057f20f883e'
  }

  constructor(private navController: NavController, private httpService: HttpService, private mineService: MineService) { }

  ngOnInit() { }

  ngAfterViewInit() { }

  async login() {
    const result = await this.httpService.login(this.user);
    if (result.code == 0) {
      this.mineService.setLoginData(result.data)
      this.navController.navigateForward('/tabs/chats')
    }
  }
}
